<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>白名单 列表</title>
<jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">

			<div class="FXBR">
				<div class="fieldBox">
					<div class="label">客户名称</div>
					<div class="field">
						<input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
					</div>
					<div class="label">证件号</div>
					<div class="field">
						<input name="certNo" id="certNo" type="text" class="ui-textbox" value="" ligerui="width: 160">
					</div>
					<div class="label">手机号</div>
					<div class="field">
						<input name="mobileNo" id="mobileNo" type="text" class="ui-textbox" value="" ligerui="width: 160">
					</div>
				</div>
			</div>

			<div class="FXBR">
				<div class="fieldBox">
					<div class="label">认证步骤</div>
					<div class="field">
						<select name="mdfStp" id="mdfStp">
							<option value="">--全部--</option>
							<option value="0">未认证</option>
							<option value="1">实名认证</option>
							<option value="2">个人信息</option>
							<option value="3">车辆信息</option>
							<option value="4">车辆状态</option>
						</select>
					</div>
					<div class="label">业务类型</div>
					<div class="field">
						<select name="busType" id="busType">
							<option value="">--全部--</option>
							<option value="0">内部</option>
							<option value="1">外部</option>
							<option value="2">物流</option>
						</select>
					</div>
				</div>
			</div>
            
            <div class="clearFix"></div>
	            <div class="btnsBox formBtns notRight">
	                <span id="searchBtn" onclick="searchBtn();" class="sq-button-round">查询</span>
	                <span id="clearBtn" onclick="clearBtn();" class="sq-button-round">清空</span>
	                <span id="addBtn" onclick="add();" class="sq-button-round">新增外部</span>
	                <span id="importCustomer"  onclick="importCustomer();" class="sq-button-round">导入客户数据</span>
	                <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
	            </div>
        	</div>
        </form>
    </div>
</div>
<div id="mcrLgsUsrgrid" class="sq-grid"></div>
</div>

<script type="text/javascript">
	var grid = null;
	$(function () {
	    initForm();
		initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
		//initEvent();
	});
	
	function initEvent(){
		 $("#redisBtn").click(function(event) {
			 var url = '<%=path%>/mcr/mcrLgsUsr/getRedisInfo.do';
			 AjaxUtils.ajaxGet(url, {}, redisCallback);
	    });
	}
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询按钮事件
	function searchBtn(){
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#mcrLgsUsrgrid").ligerGrid({
	    	url: '<%=path%>/mcr/mcrLgsUsr/initList.do',
	    	method : 'post',
	    	isSingleCheck: false,
	    	parms:getSearchParams(),
	        columns: [
				{ display: '用户ID', name: 'usrId', width: 150, enabledSort:true},
				{ display: '客户ID', name: 'cstId', width: 150, enabledSort:true },
	            { display: '客户名称', name: 'cstNm', width: 150, enabledSort:true },
	            { display: '证件号码', name: 'certNo', width: 150, enabledSort:true},
	            { display: '手机号码', name: 'mobileNo', width: 150, enabledSort:true},
	            { display: '当前是否处于黑名单', name: 'inBlack', width: 150, enabledSort:true,
					render:function(rowData){
						if(rowData.inBlack=="0"){
							return "否";
						}else {
							return "是";
						}
					}
				},
	            { display: '历史进入黑名单次数', name: 'blackTimes', width: 150, enabledSort:true},
	            { display: '公司CODE', name: 'comId', width: 150, enabledSort:true},
				{ display: '开始时间', name: 'startTm', width: 150, enabledSort:true, render:renderDate},
	            { display: '结束时间', name: 'endTm', width: 150, enabledSort:true, render:renderDate},
	            { display: '业务类型', name: 'busType', width: 150, enabledSort:true,
					render:function(rowData){
						if(rowData.busType=="0"){
							return "内部";
						}else if (rowData.busType=="1"){
							return "外部";
						}else {
							return "物流";
						}
					}
				},
	            { display: '认证步骤', name: 'mdfStp', width: 150, enabledSort:true,
					render:function(rowData){
						if(rowData.mdfStp=="0"){
							return "未认证";
						}else if (rowData.mdfStp=="1"){
							return "实名认证";
						}else if (rowData.mdfStp=="2") {
							return "个人信息";
						}else if (rowData.mdfStp=="3"){
							return "车辆信息";
						}else if (rowData.mdfStp=="4"){
							return "车辆状态";
						}else {
							return "未知步骤";
						}
					}
				},
	            { display: '物流小贷客户授信金额', name: 'lgsCreditAmt', width: 150, enabledSort:true,
					render:function(rowData,index,value){
						if(rowData.lgsCreditAmt){
							return '&yen;'+rowData.lgsCreditAmt/100;
						}
					}
				},
	            { display: '物流小贷客户授信时间', name: 'lgsCreditCrtTm',  width: 150, enabledSort:true, render:renderDate},
	            { display: '物流小贷客户授信等级', name: 'lgsCreditCstLvl', width: 150, enabledSort:true},
	            getGridOperColumnContent()
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        rownumbers:true
	    });
	    grid = liger.get("mcrLgsUsrgrid");
	    grid.setHeight(100);
	}

	// 格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}

	
  	// Grid操作列
    function getGridOperColumnContent(){
    	var data = {
                display: '操作',
                isSort: false,
                width: 280,
                render: function (rowdata, rowindex, value){
                    var out='<a class="sq-button-hasicon" href="javascript:modifyOutRow(';
						out+="'"+rowdata.id+"'";
						out+=",'mid_man_grid_id'"
						out+=")\"><i class=\"sqBtnIco_4\"></i>修改</a>"

					var lgs='<a class="sq-button-hasicon" href="javascript:modifyLgsRow(';
						lgs+="'"+rowdata.id+"'";
						lgs+=",'mid_man_grid_id'"
						lgs+=")\"><i class=\"sqBtnIco_4\"></i>修改</a>"

					if(rowdata.busType == 1){
						returnStr = out;
					}else if(rowdata.busType == 2){
						returnStr = lgs;
					}else {
						returnStr = "";
					}
					return returnStr;
                }
            }
    	return data;
	}
  	
  	//删除数据
  	function deleteRow(_id){
  		$.ligerDialog.confirm('确定删除吗?', function (flag) {
			if(flag == false)return;
			var url = '<%=path%>/mcr/mcrLgsUsr/removeById.do';
			AjaxUtils.ajaxPost(url, {id:_id}, delCallback);
		});
  	}
  	//启用禁用数据
  	function isValid(_id,isValid){
  		$.ligerDialog.confirm('确定执行该操作吗?', function (flag) {
			if(flag == false)return;
			var url = '<%=path%>/mcr/mcrLgsUsr/modify.do';
			AjaxUtils.ajaxPost(url, {id:_id,isValid:isValid}, delCallback);
		});
  	}
  	
  	//删除回调
  	function delCallback(msg){
  		if(msg.success == 1){
			 UIUtils.alertSuccess(msg.info);
			 grid.reload();
		 }else{
			 UIUtils.alertError(msg.info);
		 }
  	}

	//修改外部方法
	function modifyOutRow(_id){
		$.ligerDialog.SQopen({
			width: 800,
			height:400,
			title : '外部白名单修改',
			url:'<%=path%>/mcr/mcrLgsUsr/toAddPage.do?id='+_id,
			// 自定义buttons的时候 不要设置 fixButtons: true
			buttons: [{
				text: "保存", type: 'ok', cls: 'l-dialog-btn-ok',
				onclick: function (item, Dialog) {
					//在子页面里绑定 frameElement.dialog.onOk = function () {}
					if (Dialog.onOk) {
						Dialog.onOk();
					}
				}
			}, {
				text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no',
				onclick: function (item, Dialog) {
					//在子页面里绑定 frameElement.dialog.onCancel = function () {}
					if (Dialog.onCancel) Dialog.onCancel();
				}
			}
			]
		});
	}
  	
  	//修改方法
  	function modifyLgsRow(_id){
        $.ligerDialog.SQopen({
            width: 800,
            height:400,
            title : '物流白名单修改',
            url:'<%=path%>/mcr/mcrLgsUsr/toModifyPage.do?id='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
	                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
	                onclick: function (item, Dialog) {
	                    //在子页面里绑定 frameElement.dialog.onOk = function () {}
	                    if (Dialog.onOk) {
	                    	Dialog.onOk();
	                    }
	                }
            		}, {
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        });
  	}
  	
	//新增
	function add(){
		$.ligerDialog.SQopen({
            width: 800,
            height:400,
            title : '外部白名单新增',
            url:'<%=path%>/mcr/mcrLgsUsr/toAddPage.do',
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
                    text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onOk = function () {}
                        if (Dialog.onOk) {
                        	Dialog.onOk();
                        }
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) {
                        	Dialog.onCancel()
                        };
                    }
                }
            ]
        });
	}
	
	//查看详情
	function showDetail(_id){
		$.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 800,
            height:200,
            title : '详情',
            url:'<%=path%>/mcr/mcrLgsUsr/toDetailPage.do?id='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [ {
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) {
                        	Dialog.onCancel();
                        }
                    }
                }
            ]
        });
	}
	
  	//redis回调
  	function redisCallback(msg){
  		if(msg.success == 1){
			 UIUtils.alertSuccess(msg.data);
		 }else{
			 UIUtils.alertError(msg.info);
		 }
  	}
	

	
	//清空按钮事件
	function clearBtn(){
		 $("#resetBtn").click();  //重置 input-text
		 var form = new liger.get("searchBar");
		 form.setData({  //重置select等特殊表单
		    "cstNm":"",
		    "certNo":"",
		    "mobileNo":"",
		    "usrId":"",
		    "cstId":"",
		    "busType":""
		  });
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	
	
	//修改
	function update(){
		var selectedRows = grid.getSelectedRows();
		if(selectedRows.length != 1){
			UIUtils.alertError("请选择一条数据");
			return;
		}
		
		var _id = selectedRows[0].id;
		Add_navTab('Comp_2','修改','<%=path%>/mcr/mcrLgsUsr/toAddPage.do?id='+_id);
		
		<%-- $.ligerDialog.SQopen({
            width: 800,
            height:200,
            title : '修改',
            url:'<%=path%>/mcr/mcrLgsUsr/toAddPage.do?id='+_id,
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [{
	                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', 
	                onclick: function (item, Dialog) {
	                    //在子页面里绑定 frameElement.dialog.onOk = function () {}
	                    if (Dialog.onOk) {
	                    	Dialog.onOk();
	                    }
	                }
            		}, {
                    text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no', 
                    onclick: function (item, Dialog) {
                        //在子页面里绑定 frameElement.dialog.onCancel = function () {}
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
            ]
        }); --%>
	}

	// 导入客户信息
	function importCustomer(){
		dialogForAddMain = $.ligerDialog.SQopen({
			width: 850,
			height:400,
			title : '导入客户信息',
			url:'<%=path%>/mcr/mcrLgsUsr/toMcrCustomerPage.do',
			onClosed: function () {
			},
			onLoaded: function () {
				_subWin=dialogForAddMain.get("_subWin");
			}
		});
	}

</script>

</body>
</html>